function combineNum(arr, target) {
    // 终止条件
    let res = []
    let path = []
    let obj = {}
    let index = 0

    function genCombineNum(num) {
        // 终止条件
        if (num === target) {
            res.push(path.slice())
            return
        }
        if (num > target) {
            return
        }
        for (let i = index; i < arr.length; i++) {
            const item = arr[i];
            path.push(item)
            index = i
            genCombineNum(num + item)
            path.pop()
        }
    }
    genCombineNum(0)
    return res
}

console.log(combineNum([2, 3, 5], 8))